<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>操作样式</title>
    <script type="text/javascript" src="https://unpkg.com/vue/dist/vue.js"></script>
    <style>
        .warn{
            background-color: mistyrose;
        }
    </style>
</head>
<body>
<div id="app">
    <textarea v-model="memeText" :maxlength="limit" :class="{warn: longText}"></textarea>{{memeText.length}}
</div>

<script>
    new Vue({
        el: '#app',
        data: {
            memeText: 'What if I told you ' + 'CSS can do that',
            limit: 50
        },
        computed:{
            longText(){
                if(this.limit - this.memeText.length <= 10){
                    return true;
                }else{
                    return false;
                }
            }
        }
    })
</script>
</body>
</html>